package site.member.validator;

import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;

import site.member.domain.MemberCommand;

public class MemberJoinValidator implements Validator{

	@Override
	public boolean supports(Class<?> clazz) {
		return MemberCommand.class.isAssignableFrom(clazz);
	}

	@Override
	public void validate(Object target, Errors errors) {
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "id", "join.required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "pass", "join.required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "nick", "join.required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "name", "join.required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "email", "join.required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "question", "join.required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "answer", "join.required");
		
	}
}